<?php
class Person extends AppModel {
	var $name = 'Person';
	//The Associations below have been created with all possible keys, those that are not needed can be removed

	var $virtualFields = array(
		'full_name' => 'CONCAT(TRIM(CONCAT(Person.lastname, " ", Person.lastname2," ", Person.lastname3)),", ",TRIM(CONCAT(Person.name," ", Person.name2," ", Person.name3)))'
	);

	var $validate = array(
		'name' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Ingrese el Nombre del Paciente',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'lastname' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Ingrese el Apellido del Paciente',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'gender_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Seleccione un Género',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'sex_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Seleccione el Sexo del Paciente',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'typodocument_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Seleccione un Tipo de Documento',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'nro_documento' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Ingrese un Nro. de Documento válido',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'fecha_nacimiento' => array(
			'numeric' => array(
				'rule' => array('date'),
				'message' => 'Ingrese una fecha de nacimiento válida',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'stateperson_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Seleccione un Estado del Paciente',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		)
	);

	var $belongsTo = array(
		'Stateperson' => array(
			'className' => 'Stateperson',
			'foreignKey' => 'stateperson_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Gender' => array(
			'className' => 'Gender',
			'foreignKey' => 'gender_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Sex' => array(
			'className' => 'Sex',
			'foreignKey' => 'sex_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Typodocument' => array(
			'className' => 'Typodocument',
			'foreignKey' => 'typodocument_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		),
		'Gruposanguineo' => array(
			'className' => 'Gruposanguineo',
			'foreignKey' => 'gruposanguineo_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
	);

/*
	var $hasOne = array(
		'ClientsPerson' => array(
			'className' => 'ClientsPerson',
			'foreignKey' => 'person_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
*/

	var $hasMany = array(
		'Evolution' => array(
			'className' => 'Evolution',
			'foreignKey' => 'person_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Result' => array(
			'className' => 'Result',
			'foreignKey' => 'person_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'Turn' => array(
			'className' => 'Turn',
			'foreignKey' => 'person_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		),
		'PeoplePractice' => array(
			'className' => 'PeoplePractice',
			'foreignKey' => 'person_id',
			'dependent' => false,
		),
		'PeopleProblem' => array(
			'className' => 'PeopleProblem',
			'foreignKey' => 'person_id',
			'dependent' => false,
		),
		'PeopleRecomendation' => array(
			'className' => 'PeopleRecomendation',
			'foreignKey' => 'person_id',
			'dependent' => false,
		),
		'PeopleSign' => array(
			'className' => 'PeopleSign',
			'foreignKey' => 'person_id',
			'dependent' => false,
		),
		'PeopleVademecum' => array(
			'className' => 'PeopleVademecum',
			'foreignKey' => 'person_id',
			'dependent' => false,
		),
		'InsurancesPerson' => array(
			'className' => 'InsurancesPerson',
			'foreignKey' => 'person_id',
			'dependent' => false,
		)
	);

/*
	var $hasAndBelongsToMany = array(
		'Client' => array(
			'className' => 'Client',
			'joinTable' => 'clients_people',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'client_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Practice' => array(
			'className' => 'Practice',
			'joinTable' => 'people_practices',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'practice_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Problem' => array(
			'className' => 'Problem',
			'joinTable' => 'people_problems',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'problem_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Recomendation' => array(
			'className' => 'Recomendation',
			'joinTable' => 'people_recomendations',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'recomendation_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Sign' => array(
			'className' => 'Sign',
			'joinTable' => 'people_signs',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'sign_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		),
		'Vademecum' => array(
			'className' => 'Vademecum',
			'joinTable' => 'people_vademecums',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'vademecum_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);
*/

	var $hasAndBelongsToMany = array(
		'Client' => array(
			'className' => 'Client',
			'joinTable' => 'clients_people',
			'foreignKey' => 'person_id',
			'associationForeignKey' => 'client_id',
			'unique' => true,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'finderQuery' => '',
			'deleteQuery' => '',
			'insertQuery' => ''
		)
	);


}
?>